package org.jeecg.modules.manager.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.manager.entity.Repository;
import org.jeecg.modules.manager.entity.Stock;
import org.jeecg.modules.manager.entity.StockQueryVo;
import org.jeecg.modules.manager.mapper.StockMapper;
import org.jeecg.modules.manager.service.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 库存表
 * @Author: jeecg-boot
 * @Date:   2021-11-19
 * @Version: V1.0
 */
@Service
public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements IStockService {

    @Autowired
    StockMapper stockMapper;

    @Override
    public Page<StockQueryVo> getPage(Page<StockQueryVo> page, StockQueryVo vo) {
        List<StockQueryVo> page1 = stockMapper.getPage(page,vo);
        page1.forEach(stockQueryVo -> {
            if (!StringUtils.isNotBlank(stockQueryVo.getGoodsName())){
                stockQueryVo.setGoodsName(stockQueryVo.getGoodsName2());
            }
        });
        return page.setRecords(page1);
    }

    @Override
    public List<StockQueryVo> getPage(StockQueryVo vo) {
        List<StockQueryVo> page1 = stockMapper.getPage(vo);
        page1.forEach(stockQueryVo -> {
            if (!StringUtils.isNotBlank(stockQueryVo.getGoodsName())){
                stockQueryVo.setGoodsName(stockQueryVo.getGoodsName2());
            }
        });
        return page1;
    }
}
